package cn.maihe.elg.operation.repository.entity;

import cn.maihe.framework.starter.base.sql.BaseEntity;
import cn.maihe.framework.starter.base.sql.MapperInterface;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.FieldFill;
import com.baomidou.mybatisplus.enums.IdType;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

@TableName("t_kt_customer")
@NoArgsConstructor
@AllArgsConstructor
@Data
@Builder
@MapperInterface("cn.maihe.elg.operation.repository.mapper.KtCustomerMapper")
public class KtCustomerDO extends BaseEntity {
    /**
     * id
     */
    @TableId(type = IdType.ID_WORKER)
    private Long id;

    /**
     * 投标客户id
     */
    @TableField(value = "bidder_id")
    private Long bidderId;

    /**
     * 授权人姓名
     */
    @TableField(value = "auther_name")
    private String autherName;

    /**
     * 授权人手机号
     */
    @TableField(value = "auther_mobile")
    private String autherMobile;

    /**
     * 授权人身份证号
     */
    @TableField(value = "auther_idcard")
    private String autherIdcard;

    /**
     * 经办人姓名
     */
    @TableField(value = "handler_name")
    private String handlerName;

    /**
     * 经办人手机号
     */
    @TableField(value = "handler_mobile")
    private String handlerMobile;

    /**
     * 经办人身份证号
     */
    @TableField(value = "handler_idcard")
    private String handlerIdcard;

    /**
     * 经办人身份证照片
     */
    @TableField(value = "handler_id_pic")
    private String handlerIdPic;

    /**
     * 申请照片
     */
    @TableField(value = "apply_pic")
    private String applyPic;

    /**
     * 订单id
     */
    @TableField(value = "order_id")
    private String orderId;

    /**
     * 用户id
     */
    @TableField(value = "user_id")
    private String userId;

    /**
     * 证书名称
     */
    @TableField(value = "cert_name")
    private String certName;

    /**
     * 证书序列号
     */
    @TableField(value = "cert_number")
    private String certNumber;

    /**
     * 开始时间yyyyMMddHHmmss
     */
    @TableField(value = "cert_begin_time")
    private String certBeginTime;

    /**
     * 结束时间yyyyMMddHHmmss
     */
    @TableField(value = "cert_end_time")
    private String certEndTime;

    /**
     * 证书状态 0是找不到数据，1是待制证，2是已制证未制章，3是证章制作成功
     */
    @TableField(value = "cert_state")
    private Integer certState;

    @TableField(value = "gmt_create", fill = FieldFill.INSERT)
    private Date gmtCreate;

    @TableField(value = "gmt_modified", fill = FieldFill.INSERT_UPDATE)
    private Date gmtModified;

    @TableField(value = "user_create", fill = FieldFill.INSERT)
    private String userCreate;

    @TableField(value = "user_modified", fill = FieldFill.INSERT_UPDATE)
    private String userModified;

    /**
     * 查询次数
     */
    @TableField(value = "result_query_times")
    private Integer resultQueryTimes;

    /**
     * 管理员姓名
     */
    @TableField(value = "manager_name")
    private String managerName;

    /**
     * 管理员手机号
     */
    @TableField(value = "manager_mobile")
    private String managerMobile;

    /**
     * 管理员身份证号
     */
    @TableField(value = "manager_idcard")
    private String managerIdcard;

    /**
     * 机构主键id
     */
    @TableField(value = "org_id")
    private Long orgId;

    /**
     * 公章云签自动签章token
     */
    @TableField(value = "token")
    private String token;

    /**
     * 公章token有效期yyyyMMddHHmmss
     */
    @TableField(value = "token_expiry_time")
    private String tokenExpiryTime;

    /**
     * 证书类型1企业 2个人
     */
    @TableField(value = "cert_type")
    private String certType;

    public KtCustomerVo buildVo() {
        return new KtCustomerVo(id, bidderId, autherName, autherMobile, autherIdcard, handlerName, handlerMobile, handlerIdcard, handlerIdPic, applyPic, orderId, userId, certName, certNumber, certBeginTime, certEndTime, certState, gmtCreate, gmtModified, userCreate, userModified, resultQueryTimes, managerName, managerMobile, managerIdcard, orgId, token, tokenExpiryTime, certType);
    }

    public static KtCustomerDO of(KtCustomerVo vo) {
        return new KtCustomerDO(vo.getId(), vo.getBidderId(), vo.getAutherName(), vo.getAutherMobile(), vo.getAutherIdcard(), vo.getHandlerName(), vo.getHandlerMobile(), vo.getHandlerIdcard(), vo.getHandlerIdPic(), vo.getApplyPic(), vo.getOrderId(), vo.getUserId(), vo.getCertName(), vo.getCertNumber(), vo.getCertBeginTime(), vo.getCertEndTime(), vo.getCertState(), vo.getGmtCreate(), vo.getGmtModified(), vo.getUserCreate(), vo.getUserModified(), vo.getResultQueryTimes(), vo.getManagerName(), vo.getManagerMobile(), vo.getManagerIdcard(), vo.getOrgId(), vo.getToken(), vo.getTokenExpiryTime(), vo.getCertType());
    }
}
